#ifndef _EDITORRES_H
#define _EDITORRES_H

#include "../DES_GOBSTG/DES_GOBSTG/header/MainDependency.h"
#include "../DES_GOBSTG/DES_GOBSTG/header/Const.h"
#include "../DES_GOBSTG/DES_GOBSTG/header/DataStruct.h"
#include "../include/hgeEffectSystem.h"

#define M_ACTIVECLIENT_LEFT		0.0f
#define M_ACTIVECLIENT_RIGHT	448.0f
#define M_ACTIVECLIENT_TOP		0.0f
#define M_ACTIVECLIENT_BOTTOM	480.0f
#define M_ACTIVECLIENT_WIDTH	(M_ACTIVECLIENT_RIGHT-M_ACTIVECLIENT_LEFT)
#define M_ACTIVECLIENT_HEIGHT	(M_ACTIVECLIENT_BOTTOM-M_ACTIVECLIENT_TOP)
#define M_ACTIVECLIENT_CENTER_X	((M_ACTIVECLIENT_LEFT+M_ACTIVECLIENT_RIGHT)/2)
#define M_ACTIVECLIENT_CENTER_Y ((M_ACTIVECLIENT_TOP+M_ACTIVECLIENT_BOTTOM)/2)

#define UIITEMMAX			0x40
#define UIITEM_ITEMBEGIN	0x10

#define UIITEM_EDGE		1.5f
#define UIITEM_FONT		16

#define UIITEM_STATE_NORMAL		0x01
#define UIITEM_STATE_SELECTED	0x02
#define UIITEM_STATE_OVER		0x04

#define UIINPUTTYPE_FLOAT	0x10
#define UIINPUTTYPE_DWORD	0x20
#define UIINPUTTYPE_INT		0x40

enum{
	UIITEM_EBINFO,
	UIITEM_EEINFO,
	UIITEM_EAINFO,
	UIITEM_TITLEINFO,
	UIITEM_ADDINFO,
	UIITEM_INPUTINFO,
	UIITEM_PAGEUPINFO,
	UIITEM_PAGEDOWNINFO,
	UIITEM_BGINFO,
	UIITEM_SAVEINFO,
	UIITEM_REFRESHINFO,
};

enum{
	UIITEM_EB_NLIFETIME	=	UIITEM_ITEMBEGIN,
	UIITEM_EB_NLIFETIME_VALUE,
	UIITEM_EB_NREPEATDELAY,
	UIITEM_EB_NREPEATDELAY_VALUE,
	UIITEM_EB_TEX,
	UIITEM_EB_TEX_VALUE,

	UIITEM_EB_END
};

enum{
	UIITEM_EE_NSTARTTIME	=	UIITEM_ITEMBEGIN,
	UIITEM_EE_NSTARTTIME_VALUE,
	UIITEM_EE_NENDTIME,
	UIITEM_EE_NENDTIME_VALUE,
	UIITEM_EE_NLIFETIMEMIN,
	UIITEM_EE_NLIFETIMEMIN_VALUE,
	UIITEM_EE_NLIFETIMEMAX,
	UIITEM_EE_NLIFETIMEMAX_VALUE,
	UIITEM_EE_FEMITNUM,
	UIITEM_EE_FEMITNUM_VALUE,
	UIITEM_EE_FROTATIONX,
	UIITEM_EE_FROTATIONX_VALUE,
	UIITEM_EE_FROTATIONY,
	UIITEM_EE_FROTATIONY_VALUE,
	UIITEM_EE_FRADIUS,
	UIITEM_EE_FRADIUS_VALUE,
	UIITEM_EE_FRADIUSINNER,
	UIITEM_EE_FRADIUSINNER_VALUE,
	UIITEM_EE_FTHETASTART,
	UIITEM_EE_FTHETASTART_VALUE,
	UIITEM_EE_FTHETASTEP,
	UIITEM_EE_FTHETASTEP_VALUE,
	UIITEM_EE_FTRACERESISTANCE,
	UIITEM_EE_FTRACERESISTANCE_VALUE,
	UIITEM_EE_FTEXTUREX,
	UIITEM_EE_FTEXTUREX_VALUE,
	UIITEM_EE_FTEXTUREY,
	UIITEM_EE_FTEXTUREY_VALUE,
	UIITEM_EE_FTEXTUREW,
	UIITEM_EE_FTEXTUREW_VALUE,
	UIITEM_EE_FTEXTUREH,
	UIITEM_EE_FTEXTUREH_VALUE,
	UIITEM_EE_FHOTX,
	UIITEM_EE_FHOTX_VALUE,
	UIITEM_EE_FHOTY,
	UIITEM_EE_FHOTY_VALUE,
	UIITEM_EE_BLEND,
	UIITEM_EE_BLEND_VALUE,
	UIITEM_EE_BTRACE,
	UIITEM_EE_BTRACE_VALUE,
	UIITEM_EE_BADJUSTDIRECTION,
	UIITEM_EE_BADJUSTDIRECTION_VALUE,

	UIITEM_EE_END
};

enum{
	UIITEM_EA_NAFFECTORSTARTTIME	=	UIITEM_ITEMBEGIN,
	UIITEM_EA_NAFFECTORSTARTTIME_VALUE,
	UIITEM_EA_NAFFECTORENDTIME,
	UIITEM_EA_NAFFECTORENDTIME_VALUE,
	UIITEM_EA_NRANDOMPICKINTERVAL,
	UIITEM_EA_NRANDOMPICKINTERVAL_VALUE,
	UIITEM_EA_FSTARTVALUEMIN,
	UIITEM_EA_FSTARTVALUEMIN_VALUE,
	UIITEM_EA_FSTARTVALUEMAX,
	UIITEM_EA_FSTARTVALUEMAX_VALUE,
	UIITEM_EA_FENDVALUEMIN,
	UIITEM_EA_FENDVALUEMIN_VALUE,
	UIITEM_EA_FENDVALUEMAX,
	UIITEM_EA_FENDVALUEMAX_VALUE,
	UIITEM_EA_FINCREMENTVALUEMIN,
	UIITEM_EA_FINCREMENTVALUEMIN_VALUE,
	UIITEM_EA_FINCREMENTVALUEMAX,
	UIITEM_EA_FINCREMENTVALUEMAX_VALUE,
	UIITEM_EA_FINCREMENTSCALE,
	UIITEM_EA_FINCREMENTSCALE_VALUE,
	UIITEM_EA_FACCELERATION,
	UIITEM_EA_FACCELERATION_VALUE,
	UIITEM_EA_BUSESTARTVALUE,
	UIITEM_EA_BUSESTARTVALUE_VALUE,
	UIITEM_EA_BUSEENDVALUE,
	UIITEM_EA_BUSEENDVALUE_VALUE,
	UIITEM_EA_TYPE,
	UIITEM_EA_TYPE_VALUE,

	UIITEM_EA_END
};


struct UIinfo{
	char info[M_STRMAX];
	float x;
	float y;
	float w;
	float h;
	BYTE state;
	BYTE inputtype;
};

class EditorRes{
public:
	EditorRes();
	~EditorRes();

	bool Load();
	bool ReloadEffect(int ID);
	void ReleaseEffect(int ID);
	void Release();

	void Init();

	bool Save(int savei);

	char * GetFilename(int effi);
	char * GetFullFilename(int effi);
	char * GetAffectorName(char type);

public:
	hgeSprite * bg;
	hgeSprite * panel;
	hgeSprite * button;

	HTEXTURE tex[DATASTRUCT_TEXMAX];
	hgeFont * font;

	char filename[M_PATHMAX];
	char fullfilename[M_PATHMAX];
	char affectorname[M_STRMAX];

	UIinfo iteminfo[UIITEMMAX];

	hgeEffectSystem * eff[DATASTRUCT_EFFECTMAX];
	int texnum[DATASTRUCT_EFFECTMAX];
	int bgtex;
};

extern EditorRes eres;
extern HGE * hge;

#endif